package com.example.provider;

import java.util.List;

import com.example.model.LEARN;
import com.example.pinyin.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class LearnAdapter extends BaseAdapter {
	
	public Context mContext;
	public LayoutInflater mLayoutInflater;
	public List<LEARN> mList;
	public ViewHolder mViewHolder;
	public String mName;

	public LearnAdapter(Context context , List<LEARN> list) {
		super();
		this.mContext = context;
		this.mLayoutInflater = LayoutInflater.from(context);
		this.mList = list;
	}

	@Override
	public int getCount() {
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
	
	class ViewHolder{
		TextView tv_name;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(convertView==null){
			convertView=mLayoutInflater.inflate(R.layout.learn_adapter_item, null);
			mViewHolder = new ViewHolder();
			mViewHolder.tv_name=(TextView) convertView.findViewById(R.id.tv_name);
			convertView.setTag(mViewHolder);
		}else{
			mViewHolder = (ViewHolder) convertView.getTag();
		}
		mName = mList.get(position).getName();
		mViewHolder.tv_name.setText(mName);
		
		return convertView;
	}

}
